<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../lib/axios.js"></script>
</head>

<body>
    <button id="btn1">发起get请求</button>
    <button id="btn2">发起post请求</button>

    <script>
        document.querySelector("#btn1").addEventListener("click", function () {
            let url = "http://liulongbin.top:3006/api/get";
            let paramsObj = {
                name: "zx",
                sge: 20
            };
            axios.get(url, { params: paramsObj }).then(function (res) {
                console.log(res);
            })
        })

        document.querySelector("#btn2").addEventListener("click", function () {
            let url = "http://liulongbin.top:3006/api/post";
            let dataObj = {
                address: "中国",
                location: "西安"
            };
            axios.post(url, dataObj).then(function (res) {
                console.log(res.data);
            })
        })
    </script>
</body>

</html>